home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / pdcurs21.zip / PORTABLE.ZIP / MVSCANW.C < prev    next >
Text File  |  1992-11-21  |  3KB  |  84 lines

  1. #include <stdarg.h>
  2. #include <string.h>
  3. #define        CURSES_LIBRARY  1
  4. #include <curses.h>
  5. #undef mvscanw
  6.  
  7. #ifndef        NDEBUG
  8. char *rcsid_mvscanw = "$Header: c:/curses/portable/RCS/mvscanw.c%v 2.0 1992/11/15 03:29:01 MH Rel $";
  9. #endif
  10.  
  11.  
  12.  
  13.  
  14.  
  15. /*man-start*********************************************************************
  16.  
  17.   mvscanw()    - read formatted from window
  18.  
  19.   X/Open Description:
  20.        These routines correspond to scanf.  The function scanw reads
  21.        input from the default window.  The function wscanw reads
  22.        input from the specified window.  The function mvscanw moves
  23.        the cursor to the specified position and then reads input from
  24.        the default window.  The function mvwscanw moves the cursor to
  25.        the specified position and then reads input from the specified
  26.        window.
  27.  
  28.        For all the functions, the routine wgetstr is called to get a
  29.        string from the window, and the resulting line is used as
  30.        input for the scan.  All character interpretation is carried
  31.        out according to the scanf function rules.
  32.  
  33.   PDCurses Description:
  34.        The old Bjorn Larssen code for the 68K platform has been removed
  35.        from this module.
  36.  
  37.   X/Open Return Value:
  38.        Upon successful completion, the scanw, mvscanw, mvwscanw and
  39.        wscanw functions return the number of items successfully
  40.        matched.  On end-of-file, they return EOF.  Otherwise they
  41.        return ERR.
  42.  
  43.   PDCurses Errors:
  44.        No errors.
  45.  
  46.   Portability:
  47.        PDCurses        int mvscanw( int y, int x, char *fmt, ...);
  48.        X/Open Dec '88  int mvscanw( int y, int x, char *fmt, ...);
  49.        BSD Curses      int mvscanw( int y, int x, char *fmt, ...);
  50.        SYS V Curses    int mvscanw( int y, int x, char *fmt, ...);
  51.  
  52. **man-end**********************************************************************/
  53.  
  54. int    mvscanw(int y, int x, char *fmt, ... )
  55. {
  56.        va_list args;
  57.        int     retval = ERR;
  58.  
  59. #if    !defined (HC)
  60.        if (stdscr == (WINDOW *)NULL)
  61.                return( retval );
  62.  
  63.        if (wmove(stdscr, y, x) == ERR)
  64.                return( retval );
  65.  
  66.        wrefresh(stdscr);                       /* set cursor position */
  67.  
  68.        /*
  69.         * get string
  70.         */
  71.        c_printscanbuf[0] = '\0';  /* reset to empty string */
  72.        if (wgetstr(stdscr, c_printscanbuf) == ERR)
  73.                return( retval );
  74.        va_start(args, fmt);
  75. #ifdef NO_VSSCANF
  76.        retval = PDC_vsscanf(c_printscanbuf, fmt, args);
  77. #else
  78.        retval = vsscanf(c_printscanbuf, fmt, args);
  79. #endif
  80.        va_end(args);
  81. #endif
  82.        return( retval );
  83. }
  84.